home *** CD-ROM | disk | FTP | other *** search
- Path: news.vanderbilt.edu!news
- From: haseltbt@ctrvax.vanderbilt.edu (Bennett Haselton)
- Newsgroups: comp.lang.c++
- Subject: works in Borland but not in Microsuck Visual C++
- Date: 14 Mar 1996 22:27:52 GMT
- Organization: Vanderbilt University
- Message-ID: <4ia6h8$jes@news.vanderbilt.edu>
- NNTP-Posting-Host: dial117.vanderbilt.edu
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=ISO-8859-1
- X-Newsreader: WinVN 0.99.5
-
- Dear Abby,
-
- The following program was written in completely standard C++
- and should be portable across platforms. However, it only performs as
- expected (i.e. sends two copies of 4 to the standard out stream) in Borland
- C++; when compiled in MicroSUCK Visual C++, it outputs 4 followed by a random
- integer in the thousands.
-
- #include <iostream.h>
-
- struct person {
- int age;
- };
-
- struct person* matchPerson( struct person* psnPtr )
- {
- struct person* ansPtr;
- ansPtr->age = psnPtr->age;
- cout << ansPtr->age;
- cout << ansPtr->age;
- return ansPtr;
- };
-
- void main()
- {
- struct person myperson;
- myperson.age = 4;
- struct person* k = matchPerson( &myperson );
- }
-
- i was using version 1.0 of Visual C++; i have no knowledge of whether later
- Microsuck compilers are capable of handling a program like this properly.
- Please avoid buying their products whenever possible if you have not already
- resolved to do so.
- Is there a further explanation of this anomaly which i did not come
- across? As usual, great Microsuck jokes will be mailed to anyone who can
- help. Thanks!
-
- Love,
-
- tm
- -bennett
-
-